#include "MyStack.h"
#include <cstdio>
#include <assert.h>


bool MyStack::isEmpty(void)
{
	return m_size==0? true:false;
}

int MyStack::getSize(void)
{
	return m_size;
}

void MyStack::push(int value)
{
	++m_size;
	if(this->isEmpty())
	{
		m_pHead->m_value = value;
		m_pHead->m_pNextNode = NULL;	
	}
	else
	{
		Node* newNode = new Node;
		newNode->m_value = value;
		newNode->m_pNextNode = m_pHead;
		m_pHead = newNode;
	}
}

int MyStack::pop(void)
{
	assert(!this->isEmpty());

	int value = m_pHead->m_value;
	Node* nextNode = m_pHead->m_pNextNode;
	delete m_pHead;
	m_pHead = nextNode;
	--m_size;

	return value;
}